﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class adm_vlg_yeuCauThanhToanDetails : System.Web.UI.Page
{
    VLGDataContext _db8 = new VLGDataContext();
    YeuCauChuyenKhoan _object = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            pnMessage.Visible = true;
            ltrMessage.Text = "Thanh toán thành công";

        }
        _object = _db8.YeuCauChuyenKhoans.Single(x => x.idYCCK == Convert.ToInt32(Request.QueryString["id"]));
        FillData();

    }
    public void FillData()
    {
        if (_object != null)
        {
            hdId.Value = _object.idYCCK.ToString();
            lblTaiKhoan.Text = _object.VLGAccount.UsernameE;
            lblSoTien.Text = _object.soTien.ToString();
            lblTaiKhoanPaypal.Text = _object.tkPaypal;
            if (_object.status==true)
            {
                pnMessage.Visible = true;
                ltrMessage.Text = "Đã thanh toán cho yêu cầu này rồi, không thể thanh toán nữa !!!";
            }
        }
    }
    protected void butt_save_Click(object sender, EventArgs e)
    {
        try
        {
            _object = _db8.YeuCauChuyenKhoans.Single(x => x.idYCCK == Convert.ToInt32(hdId.Value));
            _object.maGiaoDich = txtMaGiaoDich.Text;
            _object.status = true;
            _db8.SubmitChanges();
            butt_save.Enabled = false;
            butt_save0.Enabled = false;
        }
        catch
        {
            ltrMessage.Text="Thanh toán thất bại, vui lòng thực hiện lại";
        }
        #region
        //_object = _db8.YeuCauChuyenKhoans.Single(x => x.idYCCK == Convert.ToInt32(hdId.Value));
        //PaypalProcess _paypalProcess = new PaypalProcess();
        //string returnURL = "http://localhost:23910/ViecLamGap/adm_vlg/yeuCauThanhToanSuccess.aspx";
        //string returnCancelURL = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
        //string server = "https://www.sandbox.paypal.com/cgi-bin/webscr?";
        //string business = "nhathn_1342581970_biz@gmail.com";
        //string itemName = _object.idYCCK.ToString();
        //int itemNumber = _object.idYCCK;
        //int amount = (int)_object.soTien;
        //Response.Redirect(_paypalProcess.GetPaypalProcess(returnURL, returnCancelURL, server, business, itemName, itemNumber, amount));
        #endregion
    }
}